package com.studyweb.service.impl;

import com.studyweb.mapper.CommonSenseAccumulationMapper;
import com.studyweb.pojo.entity.CommonSenseAccumulation;
import com.studyweb.service.CommonSenseAccumulationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class CommonSenseAccumulationServiceImpl implements CommonSenseAccumulationService {
    
    @Autowired
    private CommonSenseAccumulationMapper commonSenseAccumulationMapper;
    
    @Override
    public List<CommonSenseAccumulation> list() {
        return commonSenseAccumulationMapper.list();
    }
    
    @Override
    public CommonSenseAccumulation getById(Long id) {
        return commonSenseAccumulationMapper.getById(id);
    }
    
    @Override
    public void add(CommonSenseAccumulation commonSenseAccumulation) {
        commonSenseAccumulation.setStatus(0); // 默认状态为正常
        commonSenseAccumulationMapper.insert(commonSenseAccumulation);
    }
    
    @Override
    public void update(CommonSenseAccumulation commonSenseAccumulation) {
        commonSenseAccumulationMapper.update(commonSenseAccumulation);
    }
    
    @Override
    public void delete(Long id) {
        commonSenseAccumulationMapper.deleteById(id);
    }
    
    @Override
    public void batchDelete(List<Long> ids) {
        if (ids != null && !ids.isEmpty()) {
            commonSenseAccumulationMapper.batchDeleteByIds(ids);
        }
    }
    
    @Override
    public List<CommonSenseAccumulation> search(String keyword) {
        return commonSenseAccumulationMapper.listByKeyword(keyword);
    }
}